package approve.action;

import java.util.ArrayList;
import java.util.List;



import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.TextView;
import approval.dao.myapproveDAO;
import approve.adapter.My_ViewForm15_Approver_adapter;
import resource.pojo.Approvedoc;
import model.pojo.ListApprove;

public class My_ViewForm15_Approver extends Activity {

	ListView lvapprover;
	private myapproveDAO myapp=new myapproveDAO();
	private Approvedoc AppDoc=null;

	Bundle language;
	String lang = "EN",database="admin";
	public String getLang() {
		Bundle extras = getIntent().getExtras();
		if (extras != null) {
			lang = extras.getString("lang");
		}
		return lang;
	}

	public String getDatabase() {
		Bundle extras = getIntent().getExtras();
		if (extras != null) {
			database = extras.getString("database");
		}
		return database;
	}
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.my_viewform15_approver);
		
		loadBunlde();
		
		ListApprover();
	}
	
	private void loadBunlde() {
		Intent i=this.getIntent();
		AppDoc=(Approvedoc)i.getSerializableExtra("AppDoc");
		language=getIntent().getExtras().getBundle(getLang());
	}
	
	private void ListApprover(){
		lvapprover=(ListView)findViewById(R.id.lvapprover);
		My_ViewForm15_Approver_adapter adapter=new My_ViewForm15_Approver_adapter(this,loadAllApprover());
		lvapprover.setAdapter(adapter);
	}
	
	private List<ListApprove> loadAllApprover(){
		List<ListApprove> item=new ArrayList<ListApprove>();
		item=myapp.getLoadAllApprover(getDatabase(),AppDoc.getiDGroupApprove(),getLang());
		if(item.size()==0){
			TextView  nodata = new TextView(this);
    		nodata.setText(language.getString("nodata"));
    		setContentView(nodata);
		}
		else{
			return item;
		}
		return item;
	}
	
	
	private void addIntent(Intent intent){
		intent.putExtras(getIntent().getExtras());
		intent.putExtra("AppDoc", AppDoc);
		intent.putExtra("database", getDatabase());
//		startActivity(intent);
	}
}
